{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "# 手写数字识别\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. 数据载入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Standard scientific Python imports\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# Import datasets, classifiers and performance metrics\n",
    "from sklearn import datasets, svm, metrics\n",
    "\n",
    "# The digits dataset\n",
    "digits = datasets.load_digits()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. 数据分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "n_samples: 1797\n"
     ]
    }
   ],
   "source": [
    "print(\"n_samples: %s\" % len(digits.images))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = digits.images[1]\n",
    "y = digits.target[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x115277908>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPgAAAD8CAYAAABaQGkdAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAACqBJREFUeJzt3e9rnfUZx/HPZ1HZ/EVk7YY2dXEgBRkslVCQgnR1G3WK2YM9aEEhMug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v2zfLul4ROxte5YaXCTpRkmPRMRaSZ9JWtavCXUh8BlJq8+6PSTpWEuzFGX7Ys3HvSsislyRdr2kO2wf0fzTqY22n2p3pGJmJM1ExJkzrd2aD37Z6kLg70i63vZ1vRc1Nkt6seWZ+mbbmn8uNx0RD7c9TykR8WBEDEXEsOb/rV6PiDtbHquIiPhQ0lHba3pfukXSsn5RtNJlk+sUEads3yPpVUkDkh6PiP0tj1XCekl3Sfqz7ane134SES+3OBMWd6+kXb2DzWFJd7c8T19a/zUZgPp04RQdQE0IHEiMwIHECBxIjMCBxAgcSIzAgcQIHEjsP3V+m3NVnLtYAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.imshow(x, cmap=plt.cm.gray_r, interpolation='nearest')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0,  0,  0, 12, 13,  5,  0,  0],\n",
       "       [ 0,  0,  0, 11, 16,  9,  0,  0],\n",
       "       [ 0,  0,  3, 15, 16,  6,  0,  0],\n",
       "       [ 0,  7, 15, 16, 16,  2,  0,  0],\n",
       "       [ 0,  0,  1, 16, 16,  3,  0,  0],\n",
       "       [ 0,  0,  1, 16, 16,  6,  0,  0],\n",
       "       [ 0,  0,  1, 16, 16,  6,  0,  0],\n",
       "       [ 0,  0,  0, 11, 16, 10,  0,  0]])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.astype(int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {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s+4JakwBrckFcbglqTCGNySVBiDW5IKY3BLUmEMbkkqTKfquOumdc3dhfvkyZOVbbka17brtOvU1ajmppesq+3tslyd7HRqaJtOCZu7Szrk75Q+CnXbv/LKKyvbau5QX9lW934dlen0I/d9zf0dxHRqx4fBM25JKozBLUmFMbglqTAGtyQVxuCWpMIY3JJUmE6VA9aVXOXKwHJ3Vl6/fn3TLk1rCtFhqCs7ypVC5UrfcqVOXSjzyvWh7i7aTcsFc8ffqKYobWo65Wn79++vbDt06FBlWxeOE8iXLObKZQHmzZtX2XbbbbdVtuWOwVx5JQxn3DzjlqTCGNySVBiDW5IKY3BLUmEMbkkqjMEtSYXpVDlgnZkoyaor3WlbXelQrpQrVyKWK5F87LHHstscxayDuf2uKxuNiEbLdr3kL1eCtmzZsuyymzZtqmzLvQdyZaN134culAvWlY7m2pse53UlxHXjNhmecUtSYQxuSSqMwS1JhTG4JakwBrckFcbglqTCdKoccM+ePdn2sbGxyrbNmzc32mau3KkL6m4Cmyvry5Vj5UrA6sqV2r4JcV25Ve44ue6664bdnZHJfT9z+wz5McsdC7mbDO/YsSO7zabvyVHKHcu5Mcvt+zDK/ep4xi1JhTG4JakwBrckFcbglqTCGNySVBiDW5IKY3BLUmE6Vce9d+/ebPu2bdsarXfVqlWVbV2fyrOujjtXg5urNc3td9dr2+vu4r5z587Kttwdwbsu1/e64zh3N/NcDfiKFSsq2+rq6bugro+5aV1z0yLnjsFR/J2DZ9ySVBiDW5IKY3BLUmEMbkkqjMEtSYUxuCWpMJFSarsPkqQp8IxbkgpjcEtSYQxuSSqMwS1JhTG4JakwBrckFcbglqTCGNySVBiDW5IKY3BLUmEMbkkqjMEtSYUxuCWpMAa3JBXG4JakwhjcklQYg1uSCmNwS1JhDG5JKozBLUmFMbglqTAGtyQVxuCWpML8H04jDNGNlSDtAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 10 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# The data that we are interested in is made of 8x8 images of digits, let's\n",
    "# have a look at the first 10 images, stored in the `images` attribute of the\n",
    "# dataset.  If we were working from image files, we could load them using\n",
    "# matplotlib.pyplot.imread.  Note that each image must have the same size. For these\n",
    "# images, we know which digit they represent: it is given in the 'target' of\n",
    "# the dataset.\n",
    "images_and_labels = list(zip(digits.images, digits.target))\n",
    "for index, (image, label) in enumerate(images_and_labels[:10]):\n",
    "    plt.subplot(2, 5, index + 1)\n",
    "    plt.axis('off')\n",
    "    plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')\n",
    "    plt.title('label: %i' % label)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. 数据预处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# To apply a classifier on this data, we need to flatten the image, to\n",
    "# turn the data in a (samples, feature) matrix:\n",
    "n_samples = len(digits.images)\n",
    "data = digits.images.reshape((n_samples, -1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. 模型训练"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,\n",
       "  decision_function_shape='ovr', degree=3, gamma=0.001, kernel='rbf',\n",
       "  max_iter=-1, probability=False, random_state=None, shrinking=True,\n",
       "  tol=0.001, verbose=False)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Create a classifier: a support vector classifier\n",
    "classifier = svm.SVC(gamma=0.001)\n",
    "\n",
    "# We learn the digits on the first half of the digits\n",
    "classifier.fit(data[:n_samples // 2], digits.target[:n_samples // 2])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5. 预测结果评估"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Now predict the value of the digit on the second half:\n",
    "expected = digits.target[n_samples // 2:]\n",
    "predicted = classifier.predict(data[n_samples // 2:])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Classification report for classifier SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,\n",
      "  decision_function_shape='ovr', degree=3, gamma=0.001, kernel='rbf',\n",
      "  max_iter=-1, probability=False, random_state=None, shrinking=True,\n",
      "  tol=0.001, verbose=False):\n",
      "             precision    recall  f1-score   support\n",
      "\n",
      "          0       1.00      0.99      0.99        88\n",
      "          1       0.99      0.97      0.98        91\n",
      "          2       0.99      0.99      0.99        86\n",
      "          3       0.98      0.87      0.92        91\n",
      "          4       0.99      0.96      0.97        92\n",
      "          5       0.95      0.97      0.96        91\n",
      "          6       0.99      0.99      0.99        91\n",
      "          7       0.96      0.99      0.97        89\n",
      "          8       0.94      1.00      0.97        88\n",
      "          9       0.93      0.98      0.95        92\n",
      "\n",
      "avg / total       0.97      0.97      0.97       899\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\"Classification report for classifier %s:\\n%s\\n\"\n",
    "      % (classifier, metrics.classification_report(expected, predicted)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Confusion matrix:\n",
      "[[87  0  0  0  1  0  0  0  0  0]\n",
      " [ 0 88  1  0  0  0  0  0  1  1]\n",
      " [ 0  0 85  1  0  0  0  0  0  0]\n",
      " [ 0  0  0 79  0  3  0  4  5  0]\n",
      " [ 0  0  0  0 88  0  0  0  0  4]\n",
      " [ 0  0  0  0  0 88  1  0  0  2]\n",
      " [ 0  1  0  0  0  0 90  0  0  0]\n",
      " [ 0  0  0  0  0  1  0 88  0  0]\n",
      " [ 0  0  0  0  0  0  0  0 88  0]\n",
      " [ 0  0  0  1  0  1  0  0  0 90]]\n"
     ]
    }
   ],
   "source": [
    "print(\"Confusion matrix:\\n%s\" % metrics.confusion_matrix(expected, predicted))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAADuCAYAAAAZZe3jAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAEwhJREFUeJzt3X+MXWWdx/H3F4rBCLRFV4FIpwLRRF1pUf4hJq3R+IcGW901LiYrNULExEjNEmKyrC0qYhRCya4NRA2jLq4LqFP8A1Fip/6K6x/ScQUNgm0tUBsQprYLmoDP/nFO5TJO53w7c25nnvb9SprMzH3mOed+77mfOefe++0TpRQkSfU4br53QJJ0eAxuSaqMwS1JlTG4JakyBrckVcbglqTKVBXcEbE8IkpELGq/vysiLp7FPMsi4kBEHN//XtbJ2g6X9R2eY7K2pZRe/wE7gaeBA8Be4BbgpJ7mXg4UYNEs9uktfd/X5LZXAD8E9gEPAx+3tguvttZ3xn1Y1e77p6xtbzW9APgZsB/4BfDGw/n9YZ1xX1hKOQk4DzgfuGrqgGhUdcY/S18DfgCcSvME+FBEvGMO81nb5/RdW7C+zxMRJwA3Av/Tw3TWFoiIU4E7gc8BS4DPAt+OiKXZOYZaoFLKI8BdwGsBImI8Iq6JiB8DTwFnRcTiiPhSROyJiEci4lMHL1Ui4viIuC4iHo+I3wJvH5y/ne+Sge8vjYhfRcT+iLg/Is6LiK8Cy2gKcyAirpzm0uqMiLgzIp6IiAcj4tKBOTdGxG0R8ZV23vsi4g2HUYblwK2llGdLKQ8BPwJec/jVfD5rCwyptmB9B/wL8F3g14dbw0OxtlwA7C2l3N4eu/8JPAa863CK2PclwE7ayw/gTOA+4JPt9+PA72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MbkmqzIJuwJmcnOwck/mgfeaD75Bb6aLHFXAWfANOZtWaLVu2pOZas2ZN55ixsbHUXAnzWttMc02mIWZiYiK1vZGRkc4xyeaPzObmvQEnkwuZYzfTuAS5lWuOdC54xi1JlTG4JakyBrckVcbglqTKGNySVBmDW5IqY3BLUmUMbkmqzLAacCRJQ+IZtyRVxuCWpMoY3JJUGYNbkipjcEtSZQxuSaqMwS1JlTG4JakyBrckVcbglqTKGNySVBmDW5IqY3BLUmUMbkmqjMEtSZUxuCWpMga3JFXG4JakyhjcklQZg1uSKmNwS1JlDG5JqozBLUmV+X+3LcVWWiCFJAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "images_and_predictions = list(zip(digits.images[n_samples // 2:], predicted))\n",
    "for index, (image, prediction) in enumerate(images_and_predictions[:8]):\n",
    "    plt.subplot(2, 4, index + 1)\n",
    "    plt.axis('off')\n",
    "    plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')\n",
    "    plt.title('Prediction: %i' % prediction)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 模型保存"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pickle"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "pickle.dump(classifier, open('./model/clf.weights', 'wb'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = pickle.load(open('./model/clf.weights', 'rb'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 2, 3, 4, 9, 6, 7, 8, 9])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.predict(data[0:10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
